from django.db import models
from django.contrib.auth.models import User

class Article(models.Model):
    author = models.ForeignKey(User)
    boardid = models.PositiveIntegerField()
    title = models.CharField(max_length=100)
    content = models.TextField(max_length=4096)
    posttime = models.DateTimeField(auto_now=True)
    reads = models.PositiveIntegerField(default=0)
    comments = models.PositiveIntegerField(default=0)

    def __unicode__(self):
        return self.title

class Comment(models.Model):
    author = models.ForeignKey(User)
    article = models.ForeignKey(Article)
    content = models.TextField(max_length=1024)
    posttime = models.DateTimeField(auto_now=True)
    
    def __unicode__(self):
        return self.content


class UserImage(models.Model):
    user = models.ForeignKey(User)
    image = models.ImageField(upload_to="images")
    uptime = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return self.image

